
import 'package:dio/dio.dart';
import 'package:wu_you/data/repository/home_repository.dart';
import 'package:wu_you/model/home/home_model.dart';

import 'http_bloc.dart';

///国籍bloc
class LanguageBloc extends HttpBloc<List<LanguageModel>> {
  @override
  Future<List<LanguageModel>> obtainData(HttpEvent event) {
    return HomeRepository().getLanguages();
  }
}


///首页banner
class HomeInfoBloc extends HttpBloc<List<BannerModel>> {
  @override
  Future<List<BannerModel>> obtainData(HttpEvent event) {
    return HomeRepository().getBanners();
  }
}


///首页banner
class HomeNoticeBloc extends HttpBloc<List<NoticeModel>> {
  @override
  Future<List<NoticeModel>> obtainData(HttpEvent event) {
    return HomeRepository.getSimplePlatformNotice();
  }
}


///平台公告
class PlatformNoticeBloc extends HttpBloc<List<NoticeModel>> {
  PlatformNoticeBloc() : super();

  @override
  Future<List<NoticeModel>> obtainData(HttpEvent event) {
    if (event is PageSizeHttpEvent) {
      return HomeRepository.getSimplePlatformNotice(page:event.page,limit:event.size);
    }
    return Future.error(DioError(error: "请求错误", requestOptions: null));
  }
}